package com.vavr.checkincms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vavr.checkincms.domain.data.MeetingUserParamDO;
import com.vavr.checkincms.domain.dto.MeetingInfoDownloadDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * MeetingParticipantMapper
 *
 * @since 2024.08
 */
@Mapper
public interface MeetingUserParamMapper extends BaseMapper<MeetingUserParamDO> {

    @Select(" select  tel,name,organization,"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'inTime') as 'inTime',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'inDay') as 'inDay',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'inTrainNO') as 'inTrainNO',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'inTrainAddress') as 'inTrainAddress',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'outTime') as 'outTime',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'outDay') as 'outDay',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'outTrainNO') as 'outTrainNO',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'outTrainAddress') as 'outTrainAddress',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'idCard') as 'idCard',"
            + "        (select  param_value from meeting_users_param p where p.user_id = t.user_id and p.param_id = 'isAttend') as 'isAttend'"
            + " from meeting_users t where t.meeting_id = #{meetingId} order by create_time")
    @ResultType(MeetingInfoDownloadDTO.class)
    List<MeetingInfoDownloadDTO> getAllUserInfo(@Param("meetingId") String meetingId);
}
